package org.gzc.controller;

import org.gzc.exception.AuthorityException;
import org.gzc.exception.OperationException;
import org.gzc.pojo.User;
import org.gzc.service.UserService;
import org.gzc.util.PagingResultUtil;
import org.gzc.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private UserService userService;

    @RequestMapping("/user/list")
    @ResponseBody
    public PagingResultUtil<User> getUserList(User user, Integer page, Integer limit) throws Exception {
        List<User> users = userService.getUserList(user, page, limit);
        int count = userService.getTotal();
        return PagingResultUtil.success.setMsg("success").setData(users).setLimit(limit).setCurrPage(page).setCount(count);
    }

}
